/**
 * 用户名提示
 */
function focusName() {
	document.getElementById('userNameMessage').className = "message";
	document.getElementById('userNameMessage').innerHTML = "用户名的长度必须在4-16";
}

/**
 * 用户名验证
 */
function blurName() {
	var content = $('#userName').val();
	if(content.length > 16) {
		document.getElementById('userNameMessage').innerHTML = "输入的用户名长度不能大于16";
		document.getElementById('userNameMessage').className = "error";
		return false;
	} else if(content.length < 1) {
		document.getElementById('userNameMessage').innerHTML = "输入的用户名长度不能小于1";
		document.getElementById('userNameMessage').className = "error";
		return false;
	} else {
		document.getElementById('userNameMessage').innerHTML = "&nbsp;&nbsp;";
		document.getElementById('userNameMessage').className = "yes";
		return true;
	}
}
function focusWork(){
	$("#wordMessage").html("请填写你当前任职工作单位长度1-100之间");
	$("#wordMessage").removeClass("error");
	$("#wordMessage").addClass("message");
}
function blurWork(){
	if($.trim($("#word").val()).length<1){
		$("#wordMessage").html("请填写你当前任职工作单位长度1-100之间");
		$("#wordMessage").removeClass("message");
		$("#wordMessage").addClass("error");
		return false;
	}else{
		$("#wordMessage").html("&nbsp;&nbsp;");
		$("#wordMessage").addClass("yes");
		return true;
	}
}
/*出生日期校验*/
function checkBirthday(){
	if($.trim($("#date-input").val()).length<1){
		$("#birthday").html("出生日期不能为空");
		$("#birthday").addClass("error");
		return false;
	}else{
		$("#birthday").html("&nbsp;&nbsp;");
		$("#birthday").addClass("yes");
		return true;
	}
}
function checkFamily(){
	if($("#family").val()==0){
		$("#familyMessage").html("请选择您的民族");
		$("#familyMessage").addClass("error");
		return false;
	}else{
		$("#familyMessage").html("&nbsp;&nbsp;");
		$("#familyMessage").addClass("yes");
		return true;
	}
}
function checkDegree(){
	if($("#degree").val()==0){
		$("#degreeMessage").html("请选择您的最高学历");
		$("#degreeMessage").addClass("error");
		return false;
	}else{
		$("#degreeMessage").html("&nbsp;&nbsp;");
		$("#degreeMessage").addClass("yes");
		return true;
	}
}
/*清空内容*/
var message="详细地址信息不能大于80(必填项)";
function clearText(input){
	if(document.getElementById(input).value=="详细地址信息不能大于80(必填项)"){
		document.getElementById(input).value="";
	}
}
function inputText(input){
	//去空
	var reg=/\s+/g;
	var text = document.getElementById(input).value.replace(reg,"");
	if(message=="" || text.length<1){
		document.getElementById(input).value=message;
	}
}
/*店铺名称*/
function shopNameOnblur(input){
	//去空
	var reg=/\s+/g;
	var text = document.getElementById(input).value.replace(reg,"");
	document.getElementById(input).value=text;
	if(text=="" || text.length<1){
		document.getElementById("shopName").innerHTML="店铺名称不能为空！";
		document.getElementById("shopName").className="error";
		return false;
	}else if(text.length>20){
		document.getElementById("shopName").innerHTML="店铺的名称不能大于20！";
		document.getElementById("shopName").className="error";
		return false;
	}else{
		document.getElementById("shopName").innerHTML="&nbsp;&nbsp;&nbsp;";
		document.getElementById("shopName").className="yes";
	}
	return true;
}
function coaddressOnblur(input){
	//去空
	var reg=/\s+/g;
	var text = document.getElementById(input).value.replace(reg,"");
	document.getElementById(input).value=text;
	if(text.length>20){
		document.getElementById("COADDRESS").innerHTML="公司名称不能大于20！";
		document.getElementById("COADDRESS").className="error";
		return false;
	}else if(text.length>1){
		document.getElementById("COADDRESS").innerHTML="&nbsp;&nbsp;&nbsp;";
		document.getElementById("COADDRESS").className="yes";
	}
}
/*公司名称*/
function changeWord(input,inputID){
	if(document.getElementById(input).checked){
		document.getElementById(inputID).setAttribute('maxlength','20');
	}else{
		document.getElementById(inputID).value="";
		document.getElementById(inputID).setAttribute('maxlength','0');
		document.getElementById("COADDRESS").innerHTML="如果是公司开店请填写公司名称！";
		document.getElementById("COADDRESS").className="message";
	}
}
function FCKeditor_OnComplete(flag){
	if( flag=='test'){
		//address();
		if(shopNameOnblur('InputName')){
			//地址验证
			if($('[name="province"]').val()==-1 || $('[name="city"]').val()==-1 || $('[name="county"]').val()==-1){
				$('#_select').html("请选择省、市、县/区");
				$('#_select').addClass("addresserror");
				return false;
			}else{
				$('#_select').addClass("addressok");
			}
			//小地名
			if($.trim($('#address').val()).length<1 || $('#address').val()=="详细地址信息不能大于80(必填项)"){
				$("#childAddress").addClass("addresserror");
				return false;
			}
			//简介
			var oEditor = FCKeditorAPI.GetInstance('HtmlEditor') ;
			document.getElementById("book_description").value=oEditor.GetXHTML();
			if(document.getElementById("book_description").value.length<50){
				document.getElementById('synopsis').className="error";
				return false;
			}
			//地址赋值
			$('#_coaddress').val($('[name="province"]').val()+" "+$('[name="city"]').val()+" "+$('[name="county"]').val()+" "+$('#address').val());
		}else{
			return false;
		}
		//document.getElementById('address').value=document.getElementById('selProvince').value+' '+document.getElementById('selCity').value+' '+document.getElementById('address').value;
	}
	return true;
}
/*用户注册*/
function authorRegister(){
	if(blurName() && checkFamily() && checkDegree() && checkBirthday() && blurWork()){
		 ajaxFormSubmit("#right_content_space","#author_regster_form");
	}
}